{__NOLAYOUT__}
<!DOCTYPE html>
<html lang="en" class="bg-dark">

<head>
    <meta charset="UTF-8" />
    <title>下载问答记录</title>
    <link rel="shortcut icon" href="__SITEURL__/../favicon.ico" type="image/x-icon">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <link rel="stylesheet" href="__SITEURL__/css/app1.css?time=<?php echo $_SESSION['time']; ?>" type="text/css" />
</head>
<style>
    .onsubmit_msg {
        text-align: center;
        margin-top: 20px;
    }

    .progress_msg {
        margin-top: 10px;
    }

    .download_url {
        text-align: center;
        margin-top: 20px;
        display: block;
    }
</style>

<body>
    <!-- 下载问答记录数据 -->
    <div id="下载问答记录数据">
        <div class="onsubmit_msg">
            <div class="progress_msg">生成EXCEL文件中，请稍后....</div>
        </div>
        <div class="download_url">
            <a href="" target="_blank"></a>
        </div>
    </div>
</body>

<script src="__SITEURL__/uploadifive/jquery.min.js"></script>

<script>

    function getProgress() {
        $.ajax({
            type: "POST",
            url: "{:url('Qa/excelRunProgress')}",
            data: {
                excel_file: '{$excel_file}'
            },
            success: function (result) {
                console.log(result);
                if (result.code == 0) {
                    $(".progress_msg").text(result.msg);

                    setTimeout(function () {
                        getProgress();
                    }, 1000 * 1); //单位为毫秒
                } else if (result.code == 1) {
                    // 完成
                    $(".progress_msg").text(result.msg);
                    // setTimeout("window.parent.closePopupWindow();", 1000 * 5); //单位为毫秒
                }
            },
            error: function (data) {
                console.log("error:");
                console.log(data);
            }
        });
    }

    $(function () {
        // 下载问答记录数据EXCEL
        $.ajax({
            type: "POST",
            url: "{:url('Qa/downloadRecordList')}",
            data: {
                excel_file: '{$excel_file}'
            },
            success: function (result) {
                console.log(result);
                if (result.code == 0) {
                    $(".progress_msg").text(result.msg);
                    $(".download_url a").text(result.data.url);
                    $(".download_url a").attr('href', result.data.url);
                    // 调用 window.open() 函数来打开新页面
                    // window.open(result.data.url);
                }
            },
            error: function (data) {
                console.log("error:");
                console.log(data);
            }
        });

        // 启动读取进度
        setTimeout(function () {
            getProgress();
        }, 1000 * 1); //单位为毫秒
    });
</script>

</html>